package com.zwh.autoconfigure.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 广播模式, 发布订阅 ，不使用routing key匹配，直接绑定子网广播
 * @author monkey
 * @date 2020/11/3 10:58
 **/
@Configuration
public class FanoutExchangeConfig {
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("myFanout");

    }

    @Bean
    public Queue fanoutQueue1() {
        return new Queue("fanoutqueue1");
    }


    @Bean
    public Binding fanoutBinding1(){
        Binding to = BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());
        return to;

    }
}
